package com.example.server.impl;

import com.example.dao.loginMapper.LoginMapper;
import com.example.dto.login.UserLogin;
import com.example.dto.user.User;
import com.example.server.LoginServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LoginServerImpl implements LoginServer {
    @Autowired
    private LoginMapper loginMapper;

    /**
     * 登录
     *
     * @param userLogin
     * @return
     */
    @Override
    public List<User> Login(UserLogin userLogin) throws Exception {
        Map<String, Object> hash = new HashMap<>();
        hash.put("username",userLogin.getUsername());
        hash.put("password", userLogin.getPassword());

        List<User> user = loginMapper.getUserInfo(hash);
        return user;
    }

    @Override
    public List<User> getByName(String userName) {
        Map<String, Object> hash = new HashMap<>();
        hash.put("username",userName);
        return loginMapper.getUserInfo(hash);
    }

}
